package rails;

/**
 * This class represents a junction connecting to rails.
 * The two attributes rail1 and rail2 represent these two rails.
 * 
 * @author BERNARD Arthur, DELAMARCHE J�r�me, LE STER Olivier, PAVAGEAU Max
 *
 */
public class JSimple extends Jonction {
	
	/**
	 * One of the two rails connected to this junction. 
	 * 
	 * @see Rail
	 */
	private Rail rail1;
	
	/**
	 * The other one of the two rails connected to this junction.

	 * @see Rail
	 */
	private Rail rail2;

	/**
	 * A basic constructor.
	 */
	public JSimple() {
		rail1 = null;
		rail2 = null;
	}
	
	/**
	 * A constructor where we can specify the two rails connected to the junction.
	 * 
	 * @param rail1 The first rail.
	 * @param rail2 The second rail.
	 */
	public JSimple(Rail rail1, Rail rail2) {
		this.rail1 = rail1;
		this.rail2 = rail2;
	}
	
	/**
	 * Sets one of the rail of this junction.
	 * 
	 * @param rail The rail to set.
	 */
	public void setRail1(Rail rail) {
		this.rail1 = rail;
	}
	
	/**
	 * Gets one of the rail of this junction.
	 * 
	 * @return One of the rail.
	 */
	public Rail getRail1() {
		return this.rail1;
	}
	
	/**
	 * Sets one of the rail of this junction.
	 * 
	 * @param rail The rail to set.
	 */
	public void setRail2(Rail rail) {
		this.rail2 = rail;
	}
	
	/**
	 * Gets one of the rail of this junction.
	 * 
	 * @return One of the rail.
	 */
	public Rail getRail2() {
		return this.rail2;
	}
	
	public Rail railSuivant(Rail rail) {
		if(rail.equals(rail1)) {
			return rail2;
		}
		
		return rail1;
	}
	
	public String toString() {
		return "Je suis une jonction simple";
	}
}
